/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Bean;

import Action.FAQLocal;
import Entity.FAQs;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Cyrax
 */
@ManagedBean
@SessionScoped
public class FAQBean {
    @EJB
    private FAQLocal fAQ;

    private FAQs fa;
    private FAQs selectfa;
    private List<FAQs> listfa;
    /** Creates a new instance of FAQBean */
    public FAQBean() {
        fa=new FAQs();
    }

    /**
     * @return the fa
     */
    public FAQs getFa() {
        return fa;
    }

    /**
     * @param fa the fa to set
     */
    public void setFa(FAQs fa) {
        this.fa = fa;
    }
     public List<FAQs> getViewAllFAQs() {
        listfa = fAQ.viewAllFaq();
        return listfa;
    }

    public void deleteFAQs(FAQs au){
        fAQ.deleteFaq(au);
        //return "AboutUs.xhtml";
    }

    public void updateFAQs(){

         int Id=fa.getFAQId();
         fAQ.updateFaq(Id,fa.getQuestion(),fa.getAnswer());
    }

    public void addFAQs(){
        fAQ.addFaq(fa);
    }

    private String key;
    public List<FAQs> getsearchFad() {

//        if (searchType.equals("admin")) {

        listfa = fAQ.searchFAQs(getKey().toString());

//        }

        return listfa;

    }

    /**
     * @return the key
     */
    public String getKey() {
        return key;
    }

    /**
     * @param key the key to set
     */
    public void setKey(String key) {
        this.key = key;
    }

    /**
     * @return the selectfa
     */
    public FAQs getSelectfa() {
        return selectfa;
    }

    /**
     * @param selectfa the selectfa to set
     */
    public void setSelectfa(FAQs selectfa) {
        this.selectfa = selectfa;
    }

}
